<?php


/**
 * Creates Po Print Layout to pdf file using TCPDF
 * @package com.newtimes.tcpdf
 * @abstract  Po Print Layout pdf
 * @author Edo Wong
 * @since  2012-11-29
 */
function PrintPdfLayoutPof($poNo)
{
    include('db_connector.php');
    //$poNo ='4700002399';
    $sqlcheckPpkoOrNot ="SELECT * FROM  `po_dtl` WHERE  `PO_No` =  '".$poNo."' AND  `PkIndication` =  'AS'";
    $qSqlcheckPpkoOrNot= mysql_query($sqlcheckPpkoOrNot);
    $resultOfPkIndi = mysql_num_rows($qSqlcheckPpkoOrNot);
    
    $sqlcheckPpkoisNot ="SELECT * FROM  `po_dtl` WHERE  `PO_No` =  '".$poNo."' AND  (`PkIndication` ='EA' or `PkIndication` ='PR' or `PkIndication` ='ST')";
    $qSqlcheckPpkoisNot= mysql_query($sqlcheckPpkoisNot);
    $resultOfPkisnotIndi = mysql_num_rows($qSqlcheckPpkoisNot);
    
    if($resultOfPkIndi == 0){
        include('functions/poNonPrePackLayout.php');
        $printNonPpkpdfPo = PrintPdfLayoutNonPre($poNo);
        //echo $printNonPpkpdfPo;
        //echo "$resultOfPkIndi ";
        return $printNonPpkpdfPo;
    }
    else{
        
        //echo"XXX";
        //echo "$resultOfPkIndi <br>";
        if($resultOfPkisnotIndi != 0){
        include('functions/poNonPrePackLayoutV2.php');
        $printNonPpkpdfPoV2 = PrintPdfLayoutNonPreV2($poNo);
        
        //echo "$printNonPpkpdfPoV2 Non Pre <br>";
        include('functions/poPrePackLayout.php');
        $printPrePackPdfPo = PrintPdfLayoutPrePack($poNo);
        //echo "$printPrePackPdfPo Pre Pack";
        return "$printNonPpkpdfPoV2 $printPrePackPdfPo";
        }
        else{
                    include('functions/poPrePackLayout.php');
        $printPrePackPdfPo = PrintPdfLayoutPrePack($poNo);
        //echo "$printPrePackPdfPo Pre Pack";
        return "$printPrePackPdfPo";
            
        }
    }
}

require_once("nusoap/lib/nusoap.php");
$namespace = "http://localhost/edisystem/poPrintPdfLayout.php";
// create a new soap server
$server = new soap_server();
// configure our WSDL
$server->configureWSDL("PrintPdfLayoutPo");
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register our WebMethod
$server->register(
                // method name:
                'PrintPdfLayoutPof', 		 
                // parameter list:
                array('name'=>'xsd:string'), 
                // return value(s):
                array('return'=>'xsd:string'),
                // namespace:
                $namespace,
                // soapaction: (use default)
                false,
                // style: rpc or document
                'rpc',
                // use: encoded or literal
                'encoded',
                // description: documentation for the method
                'Creates Po Non Pre Pack Layout to pdf file using TCPDF web method');
                
                
// Get our posted data if the service is being consumed
// otherwise leave this data blank.                
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) 
                ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

// pass our posted data (or nothing) to the soap service                    
$server->service($POST_DATA);                
exit();


?>